package com.gxa.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.common.vo.PatientAndPatientFollowAndUser;
import com.gxa.entity.SysPatientFollow;
import com.gxa.mapper.PatientFollowMapper;
import com.gxa.service.PatientFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 患者跟进
 */
@Service
public class PatientFollowServiceImpl implements PatientFollowService {

    @Autowired
    PatientFollowMapper patientFollowMapper;

    /**
     *  获取患者跟进列表
     * @param currentPage  当前页
     * @param pageSize  没一页条数
     * @return 返回一个list
     */
    @Override
    public PageInfo getPatientFollowList(Integer currentPage,Integer pageSize) {

        PageHelper.startPage(currentPage,pageSize);
        List patientFollowList = patientFollowMapper.getPatientFollowList(currentPage, pageSize);

        PageInfo pageInfo = new PageInfo(patientFollowList);


        return pageInfo;
    }

    /**
     * 通过患者名字查找跟进列表
     * @param name 患者名字
     * @return 返回一个对象
     */
    @Override
    public PageInfo getPatientFollowByName(String name,Integer currentPage, Integer pageSize) {

        PageHelper.startPage(currentPage,pageSize);
        List patientFollowByName = patientFollowMapper.getPatientFollowByName(name);

        PageInfo pageInfo = new PageInfo(patientFollowByName);

        return pageInfo;
    }

    /**
     * 添加跟进信息
     * @param sysPatientFollow 添加的内容
     * @return 返回true或者false
     */
    @Override
    public Boolean addPatientFollow(SysPatientFollow sysPatientFollow) {

        Integer integer = patientFollowMapper.addPatientFollow(sysPatientFollow);

        return integer>0?true:false;
    }

    /**
     * 更新患者跟进信息
     * @param sysPatientFollow
     * @return 返回true或者false
     */
    @Override
    public Boolean updatePatientFollow(SysPatientFollow sysPatientFollow) {
        Integer integer = patientFollowMapper.updatePatientFollow(sysPatientFollow);
        return integer>0?true:false;
    }

    /**
     * 删除患者跟进
     * @param id 患者id
     * @return  返回true或者false
     */
    @Override
    public Boolean delPatientFollow(Integer id) {
        Integer integer = patientFollowMapper.delPatientFollow(id);
        return integer>0?true:false;
    }
}
